using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using CreamX.Framework.Game;
using System.Reflection;

namespace CreamXStudio.Screens
{
    public partial class ParticleEditor : EditorControlBase
    {

        public ParticleEditor()
        {
            InitializeComponent();
            
        }

        void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            
        }
        CreamXParticleEffect effect;
        internal override void SetData(object data)
        {
            effect = (CreamXParticleEffect)data;
            particleRenderer1.Setup(effect);
            propertyGrid1.SelectedObject = effect._emitter;
            AddProperties();
            PopulateMaterials();
            base.SetData(data);
        }

        private void PopulateMaterials()
        {
            foreach (CreamXMaterialBase mat in effect.Scene.Materials)
            {
                comboBox1.Items.Add(mat.Name);
            }
            comboBox1.Text = effect.Material.Name;
        }

        private void AddProperties()
        {
            foreach (PropertyInfo prop in effect._emitter.GetType().GetProperties())
            {
                
            }
        }

        private void propertyGrid1_Click(object sender, EventArgs e)
        {

        }

        private void propertyGrid1_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
        {
           
        }

        private void button1_Click(object sender, EventArgs e)
        {
            effect._emitter.Init();
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            effect.Material = effect.Scene.GetMaterial(comboBox1.Text);
        }
        
    }
}
